Skip to content

fix: resolve path errors and hard-coded dependencies in semantic segmentation example#371

Open
krrish175-byte wants to merge 1 commit intokubeedge:mainfrom
krrish175-byte:fix-issue-307
Open

fix: resolve path errors and hard-coded dependencies in semantic segmentation example#371
krrish175-byte wants to merge 1 commit intokubeedge:mainfrom
krrish175-byte:fix-issue-307

Conversation

@krrish175-byte
Copy link
Copy Markdown

What type of PR is this?

/kind bug
/kind cleanup

What this PR does / why we need it:
This PR resolves path errors and removes hard-coded developer dependencies in the robot/lifelong_learning_bench/semantic-segmentation examples.

Following the directory restructuring in PR #84, many configuration files were moved to the semantic-segmentation subdirectory, breaking their internal relative paths. Additionally, several YAML and Python configurations contained developer-specific absolute paths (e.g., /home/...), which prevented the example from running in other environments.

This PR:

  • Fixes broken internal references by updating them to correct relative paths.
  • Replaces hard-coded paths with standard dataset paths (/data/datasets/) and relative project paths (/ianvs/project/).
  • Scrubs out unnecessary, commented-out configuration parameters (like #workspace, #testenv, #mode) to keep the files clean and readable.

Which issue(s) this PR fixes:

Fixes #76

@kubeedge-bot kubeedge-bot added kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Feb 28, 2026
@kubeedge-bot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: krrish175-byte
To complete the pull request process, please assign jaypume after the PR has been reviewed.
You can assign the PR to them by writing /assign @jaypume in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 28, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the robustness and usability of the semantic segmentation example by addressing critical pathing issues and removing environment-specific hard-coded dependencies. The changes ensure that the example can run correctly across different environments without manual path adjustments, making it more accessible and easier to maintain for other developers.

Highlights

  • Path Resolution: Corrected numerous internal relative paths within configuration files that were broken due to a previous directory restructuring.
  • Dependency Hard-coding Removal: Replaced hard-coded absolute paths (e.g., '/home/user/...') with standardized relative project paths ('/ianvs/project/') and dataset paths ('/data/datasets/'), enhancing portability.
  • Configuration Cleanup: Removed unnecessary and commented-out configuration parameters from YAML files to improve readability and maintainability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • examples/robot/lifelong_learning_bench/semantic-segmentation/benchmarkingjob-sam.yaml
    • Updated the relative path for the 'testenv' configuration file.
    • Updated the relative path for the 'sam_algorithm.yaml' file.
    • Removed commented-out lines related to 'workspace', 'testenv', and alternative algorithms.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/benchmarkingjob-simple.yaml
    • Updated the relative path for the 'testenv' configuration file.
    • Updated the relative path for the 'rfnet_algorithm-simple.yaml' file.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testalgorithms/rfnet/RFNet/eval.py
    • Replaced hard-coded absolute paths for 'cache.pickle' and SAM model checkpoint with relative project paths.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testalgorithms/rfnet/basemodel.py
    • Replaced hard-coded absolute paths for 'train_loss_2.txt' and 'train_loss.txt' with relative project paths.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testalgorithms/rfnet/rfnet_algorithm-simple.yaml
    • Removed commented-out 'splitting_method' lines.
    • Updated relative paths for 'basemodel-simple.py', 'task_definition_by_origin-simple.py', and 'task_allocation_by_origin-simple.py'.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testalgorithms/rfnet/rfnet_algorithm.yaml
    • Removed commented-out 'splitting_method' lines.
    • Updated relative paths for 'basemodel-simple.py', 'task_definition_by_origin-simple.py', 'task_allocation_by_origin-simple.py', and 'hard_sample_mining.py'.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testalgorithms/rfnet/sam_algorithm.yaml
    • Removed commented-out 'splitting_method' lines.
    • Updated relative paths for 'basemodel-sam.py', 'task_definition_by_origin-simple.py', 'task_allocation_by_origin-simple.py', and 'hard_sample_mining.py'.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testalgorithms/rfnet/sam_vit_algorithm.yaml
    • Removed commented-out 'splitting_method' lines.
    • Updated relative paths for 'basemodel-vit-sam.py', 'task_definition_by_origin-simple.py', 'task_allocation_by_origin-simple.py', and 'hard_sample_mining.py'.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testalgorithms/rfnet/vit_algorithm.yaml
    • Removed commented-out 'splitting_method' lines.
    • Updated relative paths for 'basemodel-vit-simple.py', 'task_definition_by_origin-simple.py', 'task_allocation_by_origin-simple.py', and 'hard_sample_mining.py'.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testenv/testenv-all.yaml
    • Replaced hard-coded absolute dataset paths with standardized '/data/datasets/' paths.
    • Updated the relative path for 'accuracy.py' in model evaluation and ranking metrics.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testenv/testenv-city.yaml
    • Replaced hard-coded absolute dataset paths with standardized '/data/datasets/' paths.
    • Updated the relative path for 'accuracy.py' in model evaluation and ranking metrics.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testenv/testenv-robot-small.yaml
    • Updated the relative path for 'accuracy.py' in model evaluation and ranking metrics.
    • Removed a commented-out 'mode' line.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testenv/testenv-robot.yaml
    • Updated the relative path for 'accuracy.py' in model evaluation and ranking metrics.
    • Removed a commented-out 'mode' line.
  • examples/robot/lifelong_learning_bench/semantic-segmentation/testenv/testenv.yaml
    • Replaced hard-coded absolute dataset paths with standardized '/data/datasets/' paths.
    • Updated the relative path for 'accuracy.py' in model evaluation and ranking metrics.
Activity
  • No human activity has occurred on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

…antic segmentation

Signed-off-by: krrish175-byte <krrishbiswas175@gmail.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request does a great job of cleaning up the semantic segmentation examples by removing developer-specific absolute paths and commented-out configurations. This significantly improves the portability and readability of the code. I've identified a few remaining areas where hardcoded paths and values could be parameterized for even better flexibility, particularly concerning cache files, model checkpoints, log files, and CUDA device selection. My review includes specific suggestions to address these points.

print("load cache")
else:
sam = sam_model_registry["vit_h"](checkpoint="/home/hsj/ianvs/project/segment-anything/sam_vit_h_4b8939.pth").to('cuda:1')
sam = sam_model_registry["vit_h"](checkpoint="/ianvs/project/segment-anything/sam_vit_h_4b8939.pth").to('cuda:1')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The SAM checkpoint path ("/ianvs/project/segment-anything/sam_vit_h_4b8939.pth") and the CUDA device ('cuda:1') are hardcoded. This reduces portability and makes configuration difficult. It's better to pass these as arguments, for instance via self.args. Using a hardcoded device ID is particularly brittle and assumes a specific multi-GPU setup. A better approach would be:

sam_checkpoint = getattr(self.args, "sam_checkpoint", "/ianvs/project/segment-anything/sam_vit_h_4b8939.pth")
device = f"cuda:{self.args.gpu_ids}" if self.args.cuda else "cpu"
sam = sam_model_registry["vit_h"](checkpoint=sam_checkpoint).to(device)

print("load cache")
else:
sam = sam_model_registry["vit_h"](checkpoint="/home/hsj/ianvs/project/segment-anything/sam_vit_h_4b8939.pth").to('cuda:1')
sam = sam_model_registry["vit_h"](checkpoint="/ianvs/project/segment-anything/sam_vit_h_4b8939.pth").to('cuda:1')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The SAM checkpoint path and CUDA device are hardcoded here as well, similar to the sam_predict_ssa method. These should be parameterized for better flexibility and portability.

sam_checkpoint = getattr(self.args, "sam_checkpoint", "/ianvs/project/segment-anything/sam_vit_h_4b8939.pth")
device = f"cuda:{self.args.gpu_ids}" if self.args.cuda else "cpu"
sam = sam_model_registry["vit_h"](checkpoint=sam_checkpoint).to(device)

Comment on lines +165 to 166
with open('/ianvs/project/cache.pickle', 'rb') as file:
cache = pickle.load(file)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cache file path /ianvs/project/cache.pickle is hardcoded. This makes the code less flexible and harder to configure for different environments. It would be better to define this path as a constant or pass it as a parameter. Furthermore, the current implementation will raise a FileNotFoundError if the cache file doesn't exist (e.g., on a fresh run). It's better to handle this gracefully, for example with a try...except block:

cache_path = getattr(self.args, "cache_path", "/ianvs/project/cache.pickle")
try:
    with open(cache_path, 'rb') as file:
        cache = pickle.load(file)
except (FileNotFoundError, EOFError):
    cache = {}

Comment on lines +237 to 238
with open('/ianvs/project/cache.pickle', 'rb') as file:
cache = pickle.load(file)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cache file path /ianvs/project/cache.pickle is hardcoded here as well. This makes the code less flexible. Consider making it a configurable parameter and handling potential FileNotFoundError or EOFError as suggested for the sam_predict_ssa method.

cache_path = getattr(self.args, "cache_path", "/ianvs/project/cache.pickle")
try:
    with open(cache_path, 'rb') as file:
        cache = pickle.load(file)
except (FileNotFoundError, EOFError):
    cache = {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Real-Time IoT Perception Systems Based on Edge-Cloud Collaboration with Large Foundation Models

2 participants